package com.hll.springcrud.dao;

import com.hll.springcrud.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentDao {

    /**
     * 查询
     * @return
     */
    @Select("select * from student")
    @Results({
        @Result(id=true,property = "sid",column = "sid"),
        @Result(property = "sname",column = "sname"),
        @Result(property = "sex",column = "sex"),
        @Result(property = "classes",column = "classes"),
        @Result(property = "home",column = "home")
    })
    public List<Student>findAll();


    /**
     * 删除
     */
    @Delete("delete from student where sid=#{sid}")
    int delete(int sid);

    /**
     *查一个
     */
    @Select("select * from student where sid=#{sid}")
    Student findOne(int sid);

    /**
     * 修改
     */
    @Update("update student set sname=#{sname},sex=#{sex},classes=#{classes},home=#{home} where sid=#{sid}")
    int update(Student student);

    /**
     * 添加
     * @param student
     * @return
     */
    @Insert("insert into student (sname,sex,classes,home) value (#{sname},#{sex},#{classes},#{home})")
    int insert(Student student);


}
